package com.BraveY.Demo09;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;

public class Demo02 {
    public static void main(String[] args) {
        ArrayList<String> coll = new ArrayList<>();
        coll.add("aaa");
        coll.add("bbb");
        coll.add("ccc");
        Iterator it = coll.iterator();

        for(String str:coll){
            System.out.println(str);
        }

//        while (it.hasNext()){
//            System.out.println(it.next());
//            if("b".equals(it.next())){
//                it.remove();
//            }
//        }

        System.out.println("-----------");


        LinkedList<String> link = new LinkedList<>();
        link.add("ddd");
        link.add("eee");
        link.add("fff");
        for(String str:link){
            System.out.println(str);
        }

        Iterator itL = link.iterator();
        System.out.println("-----------");
        while (itL.hasNext()){
            System.out.println(itL.next());
            System.out.println("头："+link.getFirst());
            System.out.println("尾："+link.getLast());
        }
    }
}
